package InsLoginRegister;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class All_professors {
    java.sql.Connection conn = null;
    java.sql.Statement sqlStmt = null;
    ResultSet sqlRst = null;
    public List allprofessor()
    {
        List<managerBean> list = new ArrayList<>();
        try{
            Class.forName("org.h2.Driver");
            conn = java.sql.DriverManager.getConnection("jdbc:h2:~/jpa-demo-db;MODE=MYSQL;DB_CLOSE_DELAY=-1", "sa", "sa");
            sqlStmt = conn.createStatement();
            String sql = "select * from manager";
            sqlRst= sqlStmt.executeQuery(sql);
            while(sqlRst.next())
            {
                managerBean mb  = new managerBean();
                mb.setMNO(sqlRst.getString("MNO"));
                mb.setNAME(sqlRst.getString("NAME"));
                mb.setPNO(sqlRst.getString("PNO"));
                mb.setPASSWORD(sqlRst.getString("PASSWORD"));
                mb.setBIRTHDAY(sqlRst.getString("BIRTHDAY"));
                mb.setPHONE(sqlRst.getString("PHONE"));
                mb.setSEX(sqlRst.getString("SEX"));
                System.out.println("111");
                list.add(mb);
            }
        }
        catch (Exception ex)
        {
            System.out.println(ex.toString());
        }
        return list;
    }
}
